package com.example.springboot.prop;

import com.example.springboot.conf.YmlSourceFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 使用{@link PropertySource }和 {@link ConfigurationProperties} 读取自定义的yaml配置文件
 * <p> 默认情况下 Spring 的 @PropertySource 只支持 .properties 文件
 * <p> 如果要加载 YAML 文件，必须指定 自定义 PropertySourceFactory， 需指定PropertySource的factory
 * <p>
 * @author Zhang.Z
 * @version 2025-09-19
 */
@Component
@PropertySource(value = {"classpath:asset.yml"}, factory = YmlSourceFactory.class, encoding = "utf-8")
@ConfigurationProperties(prefix = "asset.info")
public class CustomYml {

    private String name;

    private String gateway;

    private List<String> ip;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGateway() {
        return gateway;
    }

    public void setGateway(String gateway) {
        this.gateway = gateway;
    }

    public List<String> getIp() {
        return ip;
    }

    public void setIp(List<String> ip) {
        this.ip = ip;
    }
}
